import java.applet.Applet; import java.awt.*; import java.awt.event.*; class MyFrame extends Frame implements ActionListener { String chance="X"; public MyFrame() { GridLayout lm=new GridLayout(3,3,10,10); this.setLayout(lm); Font fnt=new Font("TimesRoman",Font.BOLD,70); for(int i=0;i<9;i++) { Button btn=new Button(); (btn); btn.addActionListener(this); btn.setFont(fnt); } } public void actionPerformed(ActionEvent e) { Button bs=(Button)e.getSource(); bs.setLabel(chance); bs.setEnabled(false); if(chance.equals("X")) chance="O"; else chance="X"; } } class demo { public static void main(String argvs[]) { MyFrame frm=new MyFrame(); frm.setSize(400,300); frm.setVisible(true); } }